package gui.menu.actions;

import gui.Frame;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

public class QuitAction extends AbstractAction
{
   /** Create this action for the given frame */
   private static Icon icon = new ImageIcon("icons/quit.png");
   /**
    * 
    */
   private static final long serialVersionUID = 1L;
   private Frame frame;
   public QuitAction(Frame frame)
   {
      super("Quit",icon);
      this.frame=frame;
   }

   @Override
   public void actionPerformed(ActionEvent ae)
   {
      // if (frame.confirmSaveChanges())
      int n = JOptionPane.showConfirmDialog(
            frame,
            "Are you sure you want to quit",
            "Quit!",
            JOptionPane.YES_NO_OPTION);
      if(n==0)
         System.exit(0);
   }
}
